#!/bin/bash
# cur=

size=100 #0.1[split] 1 10 100 1000 1024 4096 #err:10000 10240
bash ../edgemesh-speed-test/randfile.sh ${size}K.bin $size K
ls -lh; sleep 2
# cat ${size}K.bin |base64 
# cat ${size}K.bin |base64 |tr -d '\n'
# msg=$(cat ${size}K.bin |base64 |tr -d '\n')

if [ "0.1" == "$size" ]; then
  bash ../edgemesh-speed-test/randfile.sh 1K.bin 1 K
  split -b 102 1K.bin
  cat xaa > 0.1K.bin
fi

cat ${size}K.bin |base64 |tr -d '\n' > ${size}K.bin.base64
# echo $msg

SERVER_IP=127.0.0.1
NODE=ido-172-29-50-53.kedge
# curl -X POST -d'{"message": "speed123"}' http://$SERVER_IP:9443/$NODE/kubeedge/topic/speedtest1
# curl -X POST -d'{"message": "'$msg'"}' http://$SERVER_IP:9443/$NODE/kubeedge/topic/speedtest1


while true; do
sleep 0.001
# curl -X POST -d'{"message": "'$msg'"}' http://$SERVER_IP:9443/$NODE/kubeedge/topic/speedtest1
curl -X POST -d @${size}K.bin.base64 http://$SERVER_IP:9443/$NODE/kubeedge/topic/speedtest1
done
